package com.example.demo2.generator.service.impl;

import com.example.demo2.generator.entity.R;
import com.example.demo2.generator.entity.WlManager;
import com.example.demo2.generator.mapper.WlManagerDao;
import com.example.demo2.generator.service.WlManagerService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.List;

/**
 * 物料管理(WlManager)表服务实现类
 *
 * @author makejava
 * @since 2024-09-26 23:40:37
 */
@Service("wlManagerService")
public class WlManagerServiceImpl implements WlManagerService {
    @Resource
    private WlManagerDao wlManagerDao;

    /**
     * 通过ID查询单条数据

     * @return 实例对象
     */
    @Override
    public List<WlManager> query(WlManager wlManager) {
        return this.wlManagerDao.query(wlManager);
    }

    /**
     * 分页查询
     *
     * @param wlManager 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<WlManager> queryByPage(WlManager wlManager, PageRequest pageRequest) {
        long total = this.wlManagerDao.count(wlManager);
        return new PageImpl<>(this.wlManagerDao.queryAllByLimit(wlManager, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param wlManager 实例对象
     * @return 实例对象
     */
    @Override
    public WlManager insert(WlManager wlManager) {
        this.wlManagerDao.insert(wlManager);
        return wlManager;
    }

    /**
     * 修改数据
     *
     * @param wlManager 实例对象
     * @return 实例对象
     */
    @Override
    public WlManager update(WlManager wlManager) {
        return this.wlManagerDao.update(wlManager);
    }

    /**
     * 通过主键删除数据
     * @return 是否成功
     */
    @Override
    public boolean delete(WlManager wlManager) {
        return this.wlManagerDao.delete(wlManager)> 0;
    }

    /**
     * 批量删除数据
     */
    @Override
    public int deletes(List<WlManager> wlManagers) {
        return wlManagerDao.deletes(wlManagers);
    }

    /**
     * 进行模糊查询
     */
    @Override
    public List<WlManager> queryByLike(WlManager wlManager) {
        return wlManagerDao.queryByLike(wlManager);
    }
}
